package DynamicProgrammingPackage;

public class findLengthOfLCIS_ {

    // 1. dp[i]表示以nums[i]结尾的子序列长度
    // 2. 递推公式: dp[i] = dp[j] + 1 if (dp[i] > dp[j])
    // 3. 初始化 dp[i] = 1;
    // 4. 从前至后遍历
    public int findLengthOfLCIS(int[] nums) {
        int[] dp = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            dp[i] = 1;
        }
        int maxValue = 1;
        for (int i = 1; i < nums.length; i++) {
                if (nums[i] > nums[i - 1]) {
                    dp[i] = dp[i - 1] + 1;
                    maxValue = Math.max(maxValue, dp[i]);
                }
        }
        return maxValue;
    }
}
